#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
const LL mod=998244353;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn];
LL cnt[maxn];
bool vis[maxn];
map<LL,LL>map1,map2;
LL ksm(LL a,LL k){
    LL res=1;
    while(k>0){
        if(k&1) res=res*a%mod;
        k>>=1;
        a=a*a%mod;
    }return res%mod;
}
int main(void)
{
  	cin.tie(0);std::ios::sync_with_stdio(false);
    LL n;cin>>n;
    for(LL i=1;i<=n;i++){
        cin>>a[i];
    }
    for(LL i=1;i<=n;i++){
        if(!map1.count(a[i])){
            map1[a[i]]=i;
        }
        else map1[a[i]]=min(map1[a[i]],i);
    }
    LL pos=n+1;
    for(LL i=n;i>=1;i--){
        if(a[i]==a[1]){
            pos=i;break;
        }
    }
    LL pos2=1;
    for(LL i=n;i>=1;i--){
        if(map1[a[i]]<=pos){
            pos2=max(pos2,i);
        }
    }
    for(LL i=n;i>=pos2+1;i--){
        if(i==map1[a[i]]) continue;
        cnt[i]++;
        cnt[map1[i]-1]--;
    }
    for(LL i=n;i>=pos2+1;i--){
        cnt[i]+=cnt[i+1];
    }
//    for(LL i=1;i<=n;i++){
//        cout<<cnt[i]<<" ";
//    }
//    cout<<"\n";
    for(LL i=1;i<=n;i++){
        if(cnt[i]) vis[i]=1;
    }
//    cout<<"\n";
//    debug(pos2);
    LL ans=0;
    for(LL i=pos2+1;i<=n;i++){
        if(vis[i]==1&&vis[i+1]==0) ans++;
    }
    for(LL i=1;i<=n;i++){
        cout<<vis[i]<<" ";
    }
    cout<<"\n";
    debug(ans);
    cout<<ksm(2,ans%mod)<<"\n";
return 0;
}
